<template>
  <div>
    <!-- <el-row>
      <el-col :span="8">
        <el-card>
          <div class="user">
            <img src="../assets/images/user.jpg" alt="" />
            <div class="userInfo">
              <p div class="name">
                {{ userInfo.name }}
              </p>
            </div>
          </div>
          <div class="loginInfo">
            <p>上次登录时间：<span>2023-11-3</span></p>
            <p>上次登陆地点：<span>上海</span></p>
          </div>
        </el-card>
      </el-col>
      <el-col :span="10">
        <div class="num">
          <el-card
            v-for="item in CountData"
            :key="item.name"
            :body-style="{ display: 'flex', padding: 0 }"
          >
            <i
              class="icon"
              :class="`el-icon-${item.icon}`"
              :style="{ backgroundColor: item.color }"
            ></i>
            <div class="details">
              <p class="price">
                {{ priceFormate(item.value) }}
              </p>
              <p class="desc">{{ item.name }}</p>
            </div>
          </el-card>
        </div>
      </el-col>
    </el-row>
    <el-row style="margin-top: 10px;">
      <el-col :span="12">
        <div
          id="main"
          style="width: 600px; height: 400px"
        ></div>
      </el-col>
      <el-col :span="12">
        <div
          id="main2"
          style="width: 600px; height: 400px"
        ></div>
      </el-col>
    </el-row> -->
  </div>
</template>

<script>
import { mapState } from "vuex";

export default {
  data() {
    return {};
  },
  methods: {
    priceFormate(price) {
      return price;
    },
    drawChart() {
      // 基于准备好的dom，初始化echarts实例  这个和上面的main对应
      let myChart = this.$echarts.init(document.getElementById("main"));
      // 指定图表的配置项和数据
      let option = {
        title: {
          text: "参赛大类类别作品数",
          left: "center",
        },
        tooltip: {
          trigger: "item",
        },
        legend: {
          orient: "vertical",
          left: "left",
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: "50%",
            data: [
              { value: 2, name: "软件应用与开发" },
              { value: 3, name: "微课与教学辅助类" },
              { value: 4, name: "3D动画设计" },
              { value: 7, name: "游戏设计" },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    },
    drawChart1() {
      let myChart = this.$echarts.init(document.getElementById("main2"));
      // 指定图表的配置项和数据
      let option = {
        xAxis: {
          type: "category",
          data: ["2018", "2019", "2020", "2021", "2022", "2023"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [150, 230, 224, 218, 135, 147],
            type: "line",
          },
        ],
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    },
  },
  mounted() {
    // this.drawChart();
    // this.drawChart1();
  },
  computed: {
    ...mapState({
      userInfo: (state) => state.user.userInfo,
    }),
  },
};
</script>

<style lang="less" scoped>
.user {
  // 垂直居中
  display: flex;
  align-items: center;

  // 外边距:分割线距离loginInfo的距离
  margin-bottom: 20px;
  // 内边距:分割线距离User的距离
  padding-bottom: 20px;
  border-bottom: 1px solid #ccc;

  img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    margin-right: 40px;
  }

  .userInfo {
    .name {
      font-size: 32px;
      margin-bottom: 10px;
    }

    .access {
      color: #999999;
    }
  }
}

.loginInfo {
  p {
    line-height: 28px;
    font-size: 14px;
    color: #999999;

    span {
      color: #666666;
      margin-left: 60px;
    }
  }
}

.num {
  display: flex;
  // 要换行
  flex-wrap: wrap;
  // 从头到尾均匀排列
  justify-content: space-between;
  margin-left: 20px;

  .el-card {
    width: 45%;
    margin-bottom: 20px;
    .icon {
      width: 80px;
      height: 80px;
      line-height: 80px;
      text-align: center;
      font-size: 30px;
      color: #fff;
    }

    .details {
      // 竖着排且居中
      display: flex;
      flex-direction: column;
      justify-content: center;

      margin-left: 15px;

      .price {
        font-size: 30px;
        margin-bottom: 10px;
        line-height: 30px;
        height: 30px;
      }

      .desc {
        font-size: 14px;
        color: #999;
        text-align: center;
      }
    }
  }
}

.graph {
  display: flex;
  // 两个靠边
  justify-content: space-between;
  margin-top: 20px;

  .el-card {
    width: 49%;
  }
}
</style>
